﻿
namespace Sai.Core.Reporting
{
    using System;

    public class MarkdownReportFormatter : IReportFormatter
    {
        public string Extension
        {
            get { return ".md"; }
        }

        public void Execute(IFlattenToXml flattenable, IReportTransformation transformation, IReportOutput output)
        {
            try
            {
                string markdown = transformation.Transform(flattenable);

                output.Execute(markdown);
            }
            catch (Exception ex)
            {
                throw new ReportGenerationException(string.Format("Error generating markdown report {0}", output.Path), ex);
            }
        }
    }
}
